home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / docs / hyper / NES-SysDoc.lha / NESTECH.TEXT
Text File  |  1998-12-10  |  93KB  |  1,629 lines

  1.        ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  2.        ³  Nintendo Entertainment System Documentation v0.40   ³
  3.        ³            by Y0SHi (yoshi@parodius.com)             ³
  4.        ³                                                      ³
  5.        ³             http://nesdev.parodius.com/              ³
  6.        ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  7.  
  8.  
  9.  
  10. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  11. ³ 0 ³   Introduction   ³
  12. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  13.  
  14.                     ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  15.                     ³ READ ME   READ ME   READ ME ³
  16.                     ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  17.  
  18.   I'd like to dedicate this document to Alex Krasivsky (Landy on IRC) for
  19. all of his help and moral support throughout the past year regarding the
  20. NES, and issues outside of the console realm. During the good times, and
  21. the bad times, Alex was there. Spasibo, Alex; umnyj russki...
  22.  
  23.                     ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  24.                     ³ READ ME   READ ME   READ ME ³
  25.                     ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  26.  
  27.   There are bound to be contradictory statements in this document. There
  28. are errors, and many problems regarding terminology (VROM vs. CHR-RAM,
  29. etc.). It is *FAR* from perfect. I have not incorporated all the terminology
  30. I would like to incorporate. Give it time and support: it'll get there.
  31.  
  32.   You will notice severe similarities between Marat Fayzullin's NES Docu-
  33. mentation and mine; I originally based my work on his. Without Marat's
  34. document, I would have never had the desire to create this one.
  35.  
  36.   Do not Email me about 6502 specifics, or such issues as "I can't figure
  37. out how to do {xxx}." I'm not interested in Emails like this; I know that
  38. sounds negative and rude, but I'm really sick and tired of getting Email
  39. about 6502 issues. Read a book. Libraries are *FULL* of 6502 books. There
  40. are tons of web pages about the 6502. I will not teach you 6502, nor any
  41. assembly language (nor do I teach UNIX). It's up to you to learn it.
  42.  
  43.   Finally, please, give credit where credit is due. All of the people in
  44. Section #15 helped contribute to this document. Be sure to thank them,
  45. as without their help, this document wouldn't be much more than a waste
  46. of bandwidth.
  47.  
  48.  
  49. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  50. ³ 1 ³   Description   ³
  51. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  52.  
  53.   The NES consists of a custom 6502 CPU, and a PPU (Picture Processing
  54. Unit) used for graphics. Programs can communicate with the NES via
  55. registers (I/O ports, so-to-speak), which allow different things to
  56. happen internally to the NES.
  57.  
  58.   There are multiple areas of memory on the NES, and they should not be
  59. confused. Terms marked with an asterisk ('*') will be the terms used
  60. from here on.
  61.  
  62. ÚÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  63. ³ Term.    ³ Description                                                 ³
  64. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  65. ³* PRG-ROM ³ Nintendo of Japan's term for the actual program code area.  ³
  66. ³          ³                                                             ³
  67. ³          ³ It stands for PRoGram ROM.                                  ³
  68. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  69. ³* CHR-RAM ³ Nintendo of Japan's term for the Pattern Table of the PPU's ³
  70. ³          ³ internal RAM.                                               ³
  71. ³          ³                                                             ³
  72. ³          ³ It stands for CHaRacter RAM.                                ³
  73. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  74. ³* VRAM    ³ The RAM internal to the PPU (Picture Processing Unit).      ³
  75. ³          ³ There is 16K of internal VRAM.                              ³
  76. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  77. ³* WRAM    ³ This is the memory which is most commonly used for games    ³
  78. ³          ³ which support saving (usually RPGs), such as Zelda 1 & 2,   ³
  79. ³          ³ Crystalis, the Final Fantasy series, and other games.       ³
  80. ³          ³                                                             ³
  81. ³          ³ It stands for Writeable RAM.                                ³
  82. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  83. ³* MMC     ³ The microcontrollers used in carts to address memory past   ³
  84. ³          ³ the standard 6502 64K boundary. They can also be used to    ³
  85. ³          ³ address extra VRAM, and may also be used for "special       ³
  86. ³          ³ effects."                                                   ³
  87. ³          ³                                                             ³
  88. ³          ³ MMC stands for Multi-Memory Controller.                     ³
  89. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  90. ³* EXRAM   ³ This is the memory which is used in MMC5, to support the    ³
  91. ³          ³ extended colour (Attributes) mode. See Section #10 for more ³
  92. ³          ³ information on this subject.                                ³
  93. ³          ³                                                             ³
  94. ³          ³ It stands for EXternal RAM.                                 ³
  95. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  96. ³ VROM     ³ The Pattern Table data kept external to the PPU itself;     ³
  97. ³          ³ standard CHR-RAM data, which is swapped in and out of the   ³
  98. ³          ³ PPU via an MMC.                                             ³
  99. ³          ³                                                             ³
  100. ³          ³ VROM stands for Video ROM.                                  ³
  101. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  102. ³ CHR      ³ Synonymous with CHR-RAM.                                    ³
  103. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  104. ³ PRG      ³ Synonymous with PRG-ROM.                                    ³
  105. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  106. ³ SRAM     ³ Synonymous with WRAM.                                       ³
  107. ÀÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  108.  
  109.  
  110. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  111. ³ 2 ³   CPU Memory Map   ³
  112. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  113.  
  114. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  115. ³ Address ³ Size  ³ Description                               ³
  116. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  117. ³ $0000   ³ $800  ³ RAM                                       ³
  118. ³ $0800   ³ $800  ³ RAM (mirrored from $0000)                 ³
  119. ³ $1000   ³ $800  ³ RAM (mirrored from $0000)                 ³
  120. ³ $1800   ³ $800  ³ RAM (mirrored from $0000)                 ³
  121. ³ $2000   ³ $3000 ³ Registers                                 ³
  122. ³ $5000   ³ $1000 ³ Expansion Modules                         ³
  123. ³ $6000   ³ $2000 ³ WRAM                                      ³
  124. ³ $8000   ³ $4000 ³ PRG-ROM (Lower)                           ³
  125. ³ $C000   ³ $4000 ³ PRG-ROM (Upper)                           ³
  126. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  127.  
  128.   Note the two seperate PRG-ROM sections; they are congruent, but they
  129. also play seperate roles, depending upon the size of the cartridge itself.
  130. Some games only hold one (1) 16K bank of PRG-ROM, which should be loaded
  131. into $C000 (Upper), not $8000 (Lower). Some games which do this are:
  132. Battle City, Mario Brothers, Millipede, Nuts & Milk, and Tennis. There
  133. are others as well.
  134.  
  135.   Most games load themselves into $8000 (Lower PRG-ROM), using 32K of
  136. PRG-ROM space. The first game (to my knowledge) to use the entire PRG-ROM
  137. space is Super Mario Brothers. However, all games with more than one (1)
  138. 16K bank of PRG-ROM load themselves into $8000 as well. These games use
  139. MMCs (see Section #10) to address PRG-ROM past the 32K boundary, and
  140. to access more than 8K of CHR-RAM simultaneously.
  141.  
  142.  
  143.  
  144. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  145. ³ 3 ³   PPU & Sprite Memory Map   ³
  146. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  147.  
  148.  PPU Memory Map
  149. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  150. ³ Address ³ Size  ³ Description                               ³
  151. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  152. ³ $0000   ³ $1000 ³ Pattern Table #0     (possibly CHR-RAM)   ³
  153. ³ $1000   ³ $1000 ³ Pattern Table #1     (possibly CHR-RAM)   ³
  154. ³ $2000   ³ $3C0  ³ Name Table #0                             ³
  155. ³ $23C0   ³ $40   ³ Attribute Table #0                        ³
  156. ³ $2400   ³ $3C0  ³ Name Table #1                             ³
  157. ³ $27C0   ³ $40   ³ Attribute Table #1                        ³
  158. ³ $2800   ³ $3C0  ³ Name Table #2        (based on mirroring) ³
  159. ³ $2BC0   ³ $40   ³ Attribute Table #2   (based on mirroring) ³
  160. ³ $2C00   ³ $3C0  ³ Name Table #3        (based on mirroring) ³
  161. ³ $2FC0   ³ $40   ³ Attribute Table #3   (based on mirroring) ³
  162. ³ $3000   ³ $F00  ³ [---EMPTY---]                             ³
  163. ³ $3F00   ³ $10   ³ Image Palette                             ³
  164. ³ $3F10   ³ $10   ³ Sprite Palette                            ³
  165. ³ $3F20   ³ $E0   ³ [---EMPTY---]                             ³
  166. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  167.  
  168.  Sprite RAM
  169. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  170. ³ Address ³ Size  ³ Description                               ³
  171. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  172. ³ $0000   ³ $100  ³ Sprite RAM                                ³
  173. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  174.  
  175.   For more information about Sprite RAM, see Sections #6 and #9.
  176.  
  177.   VRAM is quite unorganized, as shown above. To my knowledge, VRAM is
  178. addressed via 14-bit address, and therefore should wrap back around to
  179. $0000 if the memory boundary passes the end of memory ($3FFF).
  180.  
  181.   There is only enough VRAM memory to support two (2) Name Tables and
  182. two (2) Attribute Tables. Therefore, Name/Attribute Tables #2 and #3
  183. are mirrors of Name/Attribute Tables #0 and #1. Which Tables are mirrored
  184. depends upon the mirroring bit set inside of the cartridge header (see
  185. Section #12 for more information).
  186.  
  187.   In a real NES, reading/writing VRAM should only be attempted during
  188. VBlank. Many smaller ROMs have CHR-RAM for the Pattern Tables. In this
  189. case, you won't be able to write into this memory.
  190.  
  191.   Writing to VRAM
  192.   ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  193.   1) Write upper address byte into $2006
  194.   2) Write lower address byte into $2006
  195.   3) Write data into $2007. After each write, the address will auto-
  196.      increment by 1, or 32 (if Bit #2 of $2000 is 1).
  197.  
  198.   Reading from VRAM
  199.   ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  200.   1) Write upper address byte into $2006
  201.   2) Write lower address byte into $2006
  202.   3) Read data from $2007. The first read from $2007 is invalid, and
  203.      therefore should be taken care of before actual data is read.
  204.   4) Read data from $2007. From here on, after each read, the address will
  205.      auto-increment by 1, or 32 (if Bit #2 of $2000 is 1).
  206.  
  207.   The Name Table holds "tile index values." Tiles themselves are 8x8
  208. pixels. The entire Name Table itself is 32x30 tiles (256x240 pixels).
  209. However, due to NTSC and PAL frequencies, the actual displayed resolution
  210. is different.
  211.  
  212.   For NTSC, the upper and lower 16 pixels are not displayed, therefore the
  213. resolution is 256x224. The Name Table itself keeps a static size of 32x30
  214. tiles (256x240 pixels).
  215.  
  216.   These values (re: "tile index values") are usually put into the Name
  217. Table via writes to the $2006 register (see Section #6). These values are
  218. used to reference the information stored in the Pattern Table. For you
  219. emulator authors out there, the formulae is quite simple:
  220.  
  221.         (VALUE * 16) + ScreenPatternTableAddress
  222.  
  223.   Where VALUE is the value which is written to register $2006, and
  224. ScreenPatternTableAddress is the Screen Pattern Table Address defined in
  225. Bit #2 in register $2000 (see Section #6).
  226.  
  227.   The NES can only display 16 colours on the screen simultaneously.
  228.  
  229.   The Pattern Table contains tiles in the following format:
  230.  
  231.     Contents of                       Colour 
  232.    Pattern Table                      Result
  233.   ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ                    ÄÄÄÄÄÄÄÄ
  234.   %00010000 = $10 ÄÄ¿                ...1....  Periods are used to rep-
  235.   %00000000 = $00   ³                ..2.2...  resent colour 0. Numbers
  236.   %01000100 = $44   ³                .3...3..  shown represent colour #.
  237.   %00000000 = $00   ÃÄÄ Bit 0        2.....2.
  238.   %11111110 = $FE   ³                1111111.
  239.   %00000000 = $00   ³                2.....2.
  240.   %10000010 = $82   ³                3.....3.
  241.   %00000000 = $00 ÄÄÙ                ........
  242.  
  243.   %00000000 = $00 ÄÄ¿
  244.   %00101000 = $28   ³
  245.   %01000100 = $44   ³
  246.   %10000010 = $82   ÃÄÄ Bit 1
  247.   %00000000 = $00   ³
  248.   %10000010 = $82   ³
  249.   %10000010 = $82   ³
  250.   %00000000 = $00 ÄÄÙ
  251.  
  252.   The result of the above Pattern Table is the character 'A', as shown
  253. in the "Colour Result" section in the upper right.
  254.  
  255.   Only two (2) bits for each pixel of a tile are stored in the Pattern
  256. Table. The other two (2) bits are taken from the Attribute Table. Four (4)
  257. bits make up the entire possible colours on the NES, which therefore shows
  258. that the NES can display 16 colours on the screen simultaneously.
  259.  
  260.   Each byte in an Attribute Table represents a 4x4 group of tiles on the
  261. screen. There's multiple ways to describe what the function of one (1)
  262. byte in the Attribute Table does:
  263.  
  264.   * Holds the upper two (2) bits of a 32x32 pixel grid, per 16x16 pixels.
  265.   * Holds the upper two (2) bits of sixteen (16) 8x8 tiles.
  266.   * Holds the upper two (2) bits of four (4) 4x4 tile grids.
  267.  
  268.   It's confusing as hell, to be honest. A few graphical diagrams may help
  269. those who are confused:
  270.  
  271.  ÚÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ¿
  272.  ³  Square 0  ³  Square 1  ³  #0-F represents an 8x8 tile
  273.  ³   #0  #1   ³   #4  #5   ³
  274.  ³   #2  #3   ³   #6  #7   ³  Square [x] represents four (4) 8x8 tiles
  275.  ÃÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄ´   (i.e. a 16x16 pixel grid)
  276.  ³  Square 2  ³  Square 3  ³
  277.  ³   #8  #9   ³   #C  #D   ³
  278.  ³   #A  #B   ³   #E  #F   ³
  279.  ÀÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ
  280.  
  281.    Attribute Byte
  282.   ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  283.      %00000000
  284.       À´À´À´ÀÁÄ Upper two (2) colour bits for Square 0 (Tiles #0/1/2/3)
  285.        ³ ³ ÀÄÄÄ Upper two (2) colour bits for Square 1 (Tiles #4/5/6/7)
  286.        ³ ÀÄÄÄÄÄ Upper two (2) colour bits for Square 2 (Tiles #8/9/A/B)
  287.        ÀÄÄÄÄÄÄÄ Upper two (2) colour bits for Square 3 (Tiles #C/D/E/F)
  288.  
  289.   Putting all of this information together is a cinch, assuming you can
  290. overlay bit patterns in your head. A similar method is used in the tweaked
  291. graphics modes known as "MODE-X" modes on the PC. Most DOS-oriented emu-
  292. lators use what's known as "MODE-Q", since it's resolution is 256x256x256.
  293. For more information, research "chained graphics modes."
  294.  
  295.   Two (2) palettes exist; the Image Palette and the Sprite Palette. These
  296. palettes are more of a "lookup table" than an actual palette, since they
  297. do not hold physical RGB values.
  298.  
  299.   The NES itself uses an NTSC composite video signal, but can be "emulated"
  300. by corrisponding RGB values with the colours on a standard TV set. The
  301. actual 256 RGB palette can be obtained from Loopy (see Section #15).
  302.  
  303.   Mirroring also occurs between the Image Palette and the Sprite Palette.
  304. Any data which is written to $3F00 is mirrored to $3F04, $3F08, and $3F0C.
  305. Any data which is written to $3F10 is mirrored to $3F14, $3F18, and $3F1C.
  306. Colour #0 in both Palettes defines transparency.
  307.  
  308.  
  309.  
  310. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  311. ³ 4 ³   Background Scrolling   ³
  312. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  313.  
  314.   It seems there's quite a few questions regarding just how to go about
  315. using Register $2005 (see Section #6) to pan the background. I myself am
  316. still having problems understanding just exactly how this register works.
  317. But, thanks to Pat Mccomack, there is a small explanation which I'll
  318. post here so that those who're having problems can hopefully make use of
  319. this information:
  320.  
  321.   Horizontal Scrolling             Vertical Scrolling
  322.      0          512
  323.      ÚÄÄÄÄÄÂÄÄÄÄÄ¿                      ÚÄÄÄÄÄ¿0
  324.      ³     ³     ³                      ³     ³
  325.      ³  A  ³  B  ³                      ³  A  ³
  326.      ³     ³     ³                      ³     ³
  327.      ÀÄÄÄÄÄÁÄÄÄÄÄÙ                      ÃÄÄÄÄÄ´
  328.                                         ³     ³
  329.                                         ³  B  ³
  330.                                         ³     ³
  331.                                         ÀÄÄÄÄÄÙ512
  332.  
  333.   Name Table "A" is specified via Bits #0-1 in $2000 (see Section #6),
  334. and "B" is the next to "A", since it's based on mirroring. This doesn't
  335. work for game which use Horizontal & Vertical scrolling at the same time.
  336. Possibly the four-screen VRAM layout fixes this.
  337.  
  338.   "This stuff is used in smb1 (horizontal scrolling) but it's probably the
  339. same way with other games. Scrolling seems to be scanline based, ie during
  340. refresh the game can write different values to the scroll register (usually
  341. they do this when they detect the sprite 0 hit via reg $2002).  The scroll-
  342. ing screen layout also can change.  With horizontal scrolling, the name
  343. table at the first screen (0-255) is the one specified in reg $2000, and
  344. the name table for the second screen (256-512) is the opposite of the first
  345. one, based on mirroring I guess."
  346.  
  347.   Thanks for providing this information, Pat. :-)
  348.  
  349.  
  350.  
  351. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  352. ³ 5 ³   Interrupts   ³
  353. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  354.  
  355.   The 6502 has four interrupts: ABORT, IRQ/BRK, NMI, and RESET.
  356.  
  357.   Each interrupt has it's own vector, usually pointing to some code
  358. to be executed. A vector is a 16-bit address which specifies a location
  359. to "jump to" when the interrupt is triggered.
  360.  
  361.   ABORT is not controllable via software, and is a hardware interrupt
  362. which cannot be modified. It has no vector. If you're an emulator author,
  363. don't worry about emulating ABORT, as it's a pin on the 6502 chip itself.
  364.  
  365.   IRQ/BRK is triggered when the 6502 executes the BRK instruction. BRK
  366. can be used for many things, but is *RARELY* used, since it generally
  367. puts the machine into a state of unhappiness. However, for you emulator
  368. authors out there, be sure to emulate BRK correctly, as some games do
  369. use BRK to force the jump at the IRQ/BRK vector. Super Nintendo (SNES)
  370. games do this as well, but that's a different issue alltogether.
  371.  
  372.   NMI stands for Non-Maskable Interrupt, and is generated by each
  373. refresh (VBlank/VBL), which occurs at different intervals depending upon
  374. the system used. The PAL version of the NES runs at a 50Hz (50 times/sec)
  375. interval. The NTSC version runs at a 60Hz (60 times/sec) interval.
  376.  
  377.   RESET is triggered on power-up. The ROM is loaded into memory, and
  378. the 6502 jumps to the address specified in the RESET vector.
  379.  
  380.   Back to the issue of NMI. NMI is only executed 50 times/sec. when
  381. Bit #7 in $2000 (see Section #6) is set to 1. This tells the NES to
  382. generate interrupts (or more specifically, execute NMI) everytime a
  383. refresh occurs. Interrupt latency on the 6502 is seven (7) cycles; this
  384. means it takes seven (7) cycles to move in and out of an interrupt.
  385.  
  386.   Most interrupts should return using the RTI instruction. Some NES carts
  387. do not use this method, such as Final Fantasy 1. These carts return from
  388. interrupts in a very odd fashion: by manipulating the stack by hand, and
  389. then doing an RTS. This is technically valid, but morally is "bad." If
  390. you're an emulator author, just be sure you implement all your opcodes
  391. right and you should be fine. The game code will take care of the rest.
  392.  
  393.   The following interrupts have the following vector-points in ROM:
  394.  
  395.      ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄ¿
  396.      ³ Vector ³ Interrupt ³
  397.      ÃÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄ´
  398.      ³ $FFFA  ³ NMI       ³
  399.      ³ $FFFC  ³ RESET     ³
  400.      ³ $FFFE  ³ IRQ/BRK   ³
  401.      ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÙ
  402.  
  403.   Here are the correct interrupt priority orders for the 6502:
  404.  
  405.      ÚÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄ¿
  406.      ³ Priority ³ Interrupt ³
  407.      ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄ´
  408.      ³ Highest  ³ RESET     ³
  409.      ³          ³ NMI       ³
  410.      ³ Lowest   ³ IRQ/BRK   ³
  411.      ÀÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÙ
  412.  
  413.  
  414. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  415. ³ 6 ³   Registers   ³
  416. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  417.  
  418.   Address: The 16-bit address of the register (in ROM)
  419.     Stats: Each register has different statistics and "aspects" to it.
  420.            These stats are defined as follows:
  421.                R = Register is readable.
  422.                W = Register is writeable.
  423.                2 = A "double-write" register.
  424.                ? = Statistics are unknown, or are possibly wrong.
  425.      Bits: Most registers have bits you can toggle on/off which do
  426.            different things to the NES itself.
  427.      [Label]: Labels I have assigned to each register (for programmers).
  428.  
  429. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  430. ³ Address ³ Stats ³ Bits     ³ Description                       [Label]   ³
  431. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  432. ³ $2000   ³  W    ³ vhzcpwNN ³ PPU Control Register #1           [PPUCNT0] ³
  433. ³         ³       ³          ³                                             ³
  434. ³         ³       ³          ³  v = Execute NMI on VBlank                  ³
  435. ³         ³       ³          ³         0 = Disabled                        ³
  436. ³         ³       ³          ³         1 = Enabled                         ³
  437. ³         ³       ³          ³  h = Execute NMI on Sprite Hit              ³
  438. ³         ³       ³          ³         0 = Disabled                        ³
  439. ³         ³       ³          ³         1 = Enabled                         ³
  440. ³         ³       ³          ³  z = Sprite Size                            ³
  441. ³         ³       ³          ³         0 = 8x8                             ³
  442. ³         ³       ³          ³         1 = 8x16                            ³
  443. ³         ³       ³          ³  c = Screen Pattern Table Address           ³
  444. ³         ³       ³          ³         0 = $0000 (VRAM)                    ³
  445. ³         ³       ³          ³         1 = $1000 (VRAM)                    ³
  446. ³         ³       ³          ³  p = Sprite Pattern Table Address           ³
  447. ³         ³       ³          ³         0 = $0000 (VRAM)                    ³
  448. ³         ³       ³          ³         1 = $1000 (VRAM)                    ³
  449. ³         ³       ³          ³  w = PPU Address Read/Write Increment       ³
  450. ³         ³       ³          ³         0 = Increment by 1                  ³
  451. ³         ³       ³          ³         1 = Increment by 32                 ³
  452. ³         ³       ³          ³  N = Name Table Select                      ³
  453. ³         ³       ³          ³        00 = $2000 (VRAM)                    ³
  454. ³         ³       ³          ³        01 = $2400 (VRAM)                    ³
  455. ³         ³       ³          ³        10 = $2800 (VRAM)                    ³
  456. ³         ³       ³          ³        11 = $2C00 (VRAM)                    ³
  457. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  458. ³ $2001   ³  W    ³ fffpcSIt ³ PPU Control Register #2           [PPUCNT1] ³
  459. ³         ³       ³          ³                                             ³
  460. ³         ³       ³          ³  f = Full Background Colour                 ³
  461. ³         ³       ³          ³       000 = None   \                        ³
  462. ³         ³       ³          ³       001 = Red     \ Select one only       ³
  463. ³         ³       ³          ³       010 = Green   /                       ³
  464. ³         ³       ³          ³       100 = Blue   /                        ³
  465. ³         ³       ³          ³  p = Sprite Display                         ³
  466. ³         ³       ³          ³         0 = Hide sprites                    ³
  467. ³         ³       ³          ³         1 = Show sprites                    ³
  468. ³         ³       ³          ³  c = Screen Display                         ³
  469. ³         ³       ³          ³         0 = Off (screen off)                ³
  470. ³         ³       ³          ³         1 = On  (screen on)                 ³
  471. ³         ³       ³          ³  S = Sprite Clip                            ³
  472. ³         ³       ³          ³         0 = Don't show sprites in the left  ³
  473. ³         ³       ³          ³             8-pixel column                  ³
  474. ³         ³       ³          ³         1 = Show sprites everywhere         ³
  475. ³         ³       ³          ³  I = Image Clip                             ³
  476. ³         ³       ³          ³         0 = Don't show the left 8 pixels of ³
  477. ³         ³       ³          ³             the screen                      ³
  478. ³         ³       ³          ³         1 = Show the left 8 pixels          ³
  479. ³         ³       ³          ³  t = Colour Display                         ³
  480. ³         ³       ³          ³         0 = Mono-tone display               ³
  481. ³         ³       ³          ³         1 = Colour display                  ³
  482. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  483. ³ $2002   ³ R     ³ vhs00000 ³ PPU Status Register               [PPUSTAT] ³
  484. ³         ³       ³          ³                                             ³
  485. ³         ³       ³          ³  v = VBlank Occurance Flag                  ³
  486. ³         ³       ³          ³         0 = No VBlank                       ³
  487. ³         ³       ³          ³         1 = VBlank                          ³
  488. ³         ³       ³          ³  h = Hit Occurance Flag                     ³
  489. ³         ³       ³          ³         0 = No hit                          ³
  490. ³         ³       ³          ³         1 = Refresh has hit Sprite #0       ³
  491. ³         ³       ³          ³  s = Sprite Count Max                       ³
  492. ³         ³       ³          ³         0 = Less than 8 sprites on the      ³
  493. ³         ³       ³          ³             current scanline                ³
  494. ³         ³       ³          ³         1 = More than 8 sprites on the      ³
  495. ³         ³       ³          ³             current scanline                ³
  496. ³         ³       ³          ³                                             ³
  497. ³         ³       ³          ³ NOTE: Reading this register resets Bit 7,   ³
  498. ³         ³       ³          ³       also also resets the Background       ³
  499. ³         ³       ³          ³       Scroll Register bits as well.         ³
  500. ³         ³       ³          ³ NOTE: Bit 6 is reset to 0 at the beginning  ³
  501. ³         ³       ³          ³       of the next refresh.                  ³
  502. ³         ³       ³          ³ NOTE: Bit 6 is not set until the first      ³
  503. ³         ³       ³          ³       actual pixel (i.e. non-transparent)   ³
  504. ³         ³       ³          ³       is drawn. Therefore, if you have a    ³
  505. ³         ³       ³          ³       sprite (8x8) which has it's first 4   ³
  506. ³         ³       ³          ³       pixels as transparent, and it's 5th   ³
  507. ³         ³       ³          ³       as a non-transparent value, Bit 6     ³
  508. ³         ³       ³          ³       will be set after the 5th pixel is    ³
  509. ³         ³       ³          ³       found & drawn.                        ³
  510. ³         ³       ³          ³ NOTE: If Bit 5 is set, the PPU will NOT let ³
  511. ³         ³       ³          ³       you write to VRAM.                    ³
  512. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  513. ³ $2003   ³  W    ³ aaaaaaaa ³ Sprite Memory Address             [SPRADDR] ³
  514. ³         ³       ³          ³                                             ³
  515. ³         ³       ³          ³  Specifies the address in Sprite RAM to     ³
  516. ³         ³       ³          ³  access via $2004 (see Section #9).         ³
  517. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  518. ³ $2004   ³  W    ³ dddddddd ³ Sprite I/O Register                 [SPRIO] ³
  519. ³         ³       ³          ³                                             ³
  520. ³         ³       ³          ³  Used to read/write to the address spec-    ³
  521. ³         ³       ³          ³  ified via $2003 in Sprite RAM.             ³
  522. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  523. ³ $2005   ³  W2   ³ dddddddd ³ Background Scroll Register        [BGSCROL] ³
  524. ³         ³       ³          ³                                             ³
  525. ³         ³       ³          ³  Used to scroll the screen vertically and   ³
  526. ³         ³       ³          ³  horizontally. This is a double-write       ³
  527. ³         ³       ³          ³  register.                                  ³
  528. ³         ³       ³          ³                                             ³
  529. ³         ³       ³          ³  BYTE 1: Horizontal Scroll                  ³
  530. ³         ³       ³          ³  BYTE 2: Vertical Scroll                    ³
  531. ³         ³       ³          ³                                             ³
  532. ³         ³       ³          ³  The scrolled data will span across multip- ³
  533. ³         ³       ³          ³  le Name Tables. The layout is as follows:  ³
  534. ³         ³       ³          ³                                             ³
  535. ³         ³       ³          ³      ÚÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ¿            ³
  536. ³         ³       ³          ³      ³ #2 ($2800) ³ #3 ($2C00) ³            ³
  537. ³         ³       ³          ³      ÃÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄ´            ³
  538. ³         ³       ³          ³      ³ #0 ($2000) ³ #1 ($2400) ³            ³
  539. ³         ³       ³          ³      ÀÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ            ³
  540. ³         ³       ³          ³                                             ³
  541. ³         ³       ³          ³ NOTE: If the Vertical Scroll value is >239, ³
  542. ³         ³       ³          ³       it will be ignored. Some emulators    ³
  543. ³         ³       ³          ³       write 0 to the Vertical Scroll if     ³
  544. ³         ³       ³          ³       the value is >239.                    ³
  545. ³         ³       ³          ³ NOTE: Remember, there is only enough VRAM   ³
  546. ³         ³       ³          ³       for two (2) Name Tables.              ³
  547. ³         ³       ³          ³ NOTE: After a VBL occurs, the next write    ³
  548. ³         ³       ³          ³       will control the Horizontal Scroll.   ³
  549. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  550. ³ $2006   ³  W2   ³ aaaaaaaa ³ PPU Memory Address                [PPUADDR] ³
  551. ³         ³       ³          ³                                             ³
  552. ³         ³       ³          ³  Specifies the address in VRAM in which     ³
  553. ³         ³       ³          ³  data should be read from or written to.    ³
  554. ³         ³       ³          ³  This is a double-write register. The high- ³
  555. ³         ³       ³          ³  byte of the 16-bit address is written      ³
  556. ³         ³       ³          ³  first, then the low-byte.                  ³
  557. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  558. ³ $2007   ³ RW    ³ dddddddd ³ PPU I/O Register                    [PPUIO] ³
  559. ³         ³       ³          ³                                             ³
  560. ³         ³       ³          ³  Used to read/write to the address spec-    ³
  561. ³         ³       ³          ³  ified via $2006 in VRAM.                   ³
  562. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  563. ³ $4000   ³ RW    ³ CChessss ³ Square Wave Control Register #1             ³
  564. ³         ³       ³          ³                                             ³
  565. ³         ³       ³          ³   C = Duty Cycle (Positive vs. Negative)    ³
  566. ³         ³       ³          ³        00 = 87.5%                           ³
  567. ³         ³       ³          ³        01 = 75.0%                           ³
  568. ³         ³       ³          ³        10 = 58.0%                           ³
  569. ³         ³       ³          ³        11 = 25.0%                           ³
  570. ³         ³       ³          ³   h = Hold Note                             ³
  571. ³         ³       ³          ³         0 = Don't hold note                 ³
  572. ³         ³       ³          ³         1 = Hold note                       ³
  573. ³         ³       ³          ³   e = Envelope Select                       ³
  574. ³         ³       ³          ³         0 = Envelope Vary                   ³
  575. ³         ³       ³          ³         1 = Envelope Fixed                  ³
  576. ³         ³       ³          ³   s = Playback Rate                         ³
  577. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  578. ³ $4001   ³ RW    ³ fsssHrrr ³ Square Wave Control Register #2             ³
  579. ³         ³       ³          ³                                             ³
  580. ³         ³       ³          ³   f = Frequency Fixed/Variable Select       ³
  581. ³         ³       ³          ³          0 = Fixed  (bits 0-6 disabled)     ³
  582. ³         ³       ³          ³          1 = Variable (bits 0-6 enabled)    ³
  583. ³         ³       ³          ³   s = Frequency Change Speed                ³
  584. ³         ³       ³          ³   H = Low/High Frequency Select             ³
  585. ³         ³       ³          ³          0 = Low -> High                    ³
  586. ³         ³       ³          ³          1 = High -> Low                    ³
  587. ³         ³       ³          ³   r = Frequency Range (0=Min, 7=Max)        ³
  588. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  589. ³ $4002   ³ RW    ³ dddddddd ³ Square Wave Frequency Value Register #1     ³
  590. ³         ³       ³          ³                                             ³
  591. ³         ³       ³          ³   d = Frequency Value Data (lower 8-bits)   ³
  592. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  593. ³ $4003   ³ RW    ³ tttttddd ³ Square Wave Frequency Value Register #2     ³
  594. ³         ³       ³          ³                                             ³
  595. ³         ³       ³          ³   d = Frequency Value Data (upper 3-bits)   ³
  596. ³         ³       ³          ³   t = Active Time Length                    ³
  597. ³         ³       ³          ³                                             ³
  598. ³         ³       ³          ³ NOTE: The Frequency Value is a full 11-bits ³
  599. ³         ³       ³          ³       in size; be aware you will need to    ³
  600. ³         ³       ³          ³       write the upper 3-bits to $4003.      ³
  601. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  602. ³ $4004   ³ RW    ³ CChessss ³ Square Wave Control Register #1             ³
  603. ³         ³       ³          ³                                             ³
  604. ³         ³       ³          ³   C = Duty Cycle (Positive vs. Negative)    ³
  605. ³         ³       ³          ³        00 = 87.5%                           ³
  606. ³         ³       ³          ³        01 = 75.0%                           ³
  607. ³         ³       ³          ³        10 = 58.0%                           ³
  608. ³         ³       ³          ³        11 = 25.0%                           ³
  609. ³         ³       ³          ³   h = Hold Note                             ³
  610. ³         ³       ³          ³         0 = Don't hold note                 ³
  611. ³         ³       ³          ³         1 = Hold note                       ³
  612. ³         ³       ³          ³   e = Envelope Select                       ³
  613. ³         ³       ³          ³         0 = Envelope Vary                   ³
  614. ³         ³       ³          ³         1 = Envelope Fixed                  ³
  615. ³         ³       ³          ³   s = Playback Rate                         ³
  616. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  617. ³ $4005   ³ RW    ³ fsssHrrr ³ Square Wave Control Register #2             ³
  618. ³         ³       ³          ³                                             ³
  619. ³         ³       ³          ³   f = Frequency Fixed/Variable Select       ³
  620. ³         ³       ³          ³          0 = Fixed  (bits 0-6 disabled)     ³
  621. ³         ³       ³          ³          1 = Variable (bits 0-6 enabled)    ³
  622. ³         ³       ³          ³   s = Frequency Change Speed                ³
  623. ³         ³       ³          ³   H = Low/High Frequency Select             ³
  624. ³         ³       ³          ³          0 = Low -> High                    ³
  625. ³         ³       ³          ³          1 = High -> Low                    ³
  626. ³         ³       ³          ³   r = Frequency Range (0=Min, 7=Max)        ³
  627. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  628. ³ $4006   ³ RW    ³ dddddddd ³ Square Wave Frequency Value Register #1     ³
  629. ³         ³       ³          ³                                             ³
  630. ³         ³       ³          ³   d = Frequency Value Data (lower 8-bits)   ³
  631. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  632. ³ $4007   ³ RW    ³ tttttddd ³ Square Wave Frequency Value Register #2     ³
  633. ³         ³       ³          ³                                             ³
  634. ³         ³       ³          ³   d = Frequency Value Data (upper 3-bits)   ³
  635. ³         ³       ³          ³   t = Active Time Length                    ³
  636. ³         ³       ³          ³                                             ³
  637. ³         ³       ³          ³ NOTE: The Frequency Value is a full 11-bits ³
  638. ³         ³       ³          ³       in size; be aware you will need to    ³
  639. ³         ³       ³          ³       write the upper 3-bits to $4007.      ³
  640. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  641. ³ $4008   ³ RW    ³ CChessss ³ Triangle Wave Control Register #1           ³
  642. ³         ³       ³          ³                                             ³
  643. ³         ³       ³          ³   C = Duty Cycle (Positive vs. Negative)    ³
  644. ³         ³       ³          ³        00 = 87.5%                           ³
  645. ³         ³       ³          ³        01 = 75.0%                           ³
  646. ³         ³       ³          ³        10 = 58.0%                           ³
  647. ³         ³       ³          ³        11 = 25.0%                           ³
  648. ³         ³       ³          ³   h = Hold Note                             ³
  649. ³         ³       ³          ³         0 = Don't hold note                 ³
  650. ³         ³       ³          ³         1 = Hold note                       ³
  651. ³         ³       ³          ³   e = Envelope Select                       ³
  652. ³         ³       ³          ³         0 = Envelope Vary                   ³
  653. ³         ³       ³          ³         1 = Envelope Fixed                  ³
  654. ³         ³       ³          ³   s = Playback Rate                         ³
  655. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  656. ³ $4009   ³ RW    ³ fsssHrrr ³ Triangle Wave Control Register #2           ³
  657. ³         ³       ³          ³                                             ³
  658. ³         ³       ³          ³   f = Frequency Fixed/Variable Select       ³
  659. ³         ³       ³          ³          0 = Fixed  (bits 0-6 disabled)     ³
  660. ³         ³       ³          ³          1 = Variable (bits 0-6 enabled)    ³
  661. ³         ³       ³          ³   s = Frequency Change Speed                ³
  662. ³         ³       ³          ³   H = Low/High Frequency Select             ³
  663. ³         ³       ³          ³          0 = Low -> High                    ³
  664. ³         ³       ³          ³          1 = High -> Low                    ³
  665. ³         ³       ³          ³   r = Frequency Range (0=Min, 7=Max)        ³
  666. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  667. ³ $400A   ³ RW    ³ dddddddd ³ Triangle Wave Frequency Value Register #1   ³
  668. ³         ³       ³          ³                                             ³
  669. ³         ³       ³          ³   d = Frequency Value Data (lower 8-bits)   ³
  670. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  671. ³ $400B   ³ RW    ³ tttttddd ³ Triangle Wave Frequency Value Register #2   ³
  672. ³         ³       ³          ³                                             ³
  673. ³         ³       ³          ³   d = Frequency Value Data (upper 3-bits)   ³
  674. ³         ³       ³          ³   t = Active Time Length                    ³
  675. ³         ³       ³          ³                                             ³
  676. ³         ³       ³          ³ NOTE: The Frequency Value is a full 11-bits ³
  677. ³         ³       ³          ³       in size; be aware you will need to    ³
  678. ³         ³       ³          ³       write the upper 3-bits to $400B.      ³
  679. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  680. ³ $400C   ³ RW    ³ CChessss ³ Noise Control Register #1                   ³
  681. ³         ³       ³          ³                                             ³
  682. ³         ³       ³          ³   C = Duty Cycle (Positive vs. Negative)    ³
  683. ³         ³       ³          ³        00 = 87.5%                           ³
  684. ³         ³       ³          ³        01 = 75.0%                           ³
  685. ³         ³       ³          ³        10 = 58.0%                           ³
  686. ³         ³       ³          ³        11 = 25.0%                           ³
  687. ³         ³       ³          ³   h = Hold Note                             ³
  688. ³         ³       ³          ³         0 = Don't hold note                 ³
  689. ³         ³       ³          ³         1 = Hold note                       ³
  690. ³         ³       ³          ³   e = Envelope Select                       ³
  691. ³         ³       ³          ³         0 = Envelope Vary                   ³
  692. ³         ³       ³          ³         1 = Envelope Fixed                  ³
  693. ³         ³       ³          ³   s = Playback Rate                         ³
  694. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  695. ³ $400D   ³ RW    ³ fsssHrrr ³ Noise Control Register #2                   ³
  696. ³         ³       ³          ³                                             ³
  697. ³         ³       ³          ³   f = Frequency Fixed/Variable Select       ³
  698. ³         ³       ³          ³          0 = Fixed  (bits 0-6 disabled)     ³
  699. ³         ³       ³          ³          1 = Variable (bits 0-6 enabled)    ³
  700. ³         ³       ³          ³   s = Frequency Change Speed                ³
  701. ³         ³       ³          ³   H = Low/High Frequency Select             ³
  702. ³         ³       ³          ³          0 = Low -> High                    ³
  703. ³         ³       ³          ³          1 = High -> Low                    ³
  704. ³         ³       ³          ³   r = Frequency Range (0=Min, 7=Max)        ³
  705. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  706. ³ $400E   ³ RW    ³ dddddddd ³ Frequency Value Register #1                 ³
  707. ³         ³       ³          ³                                             ³
  708. ³         ³       ³          ³   d = Frequency Value Data (lower 8-bits)   ³
  709. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  710. ³ $400F   ³ RW    ³ tttttddd ³ Frequency Value Register #2                 ³
  711. ³         ³       ³          ³                                             ³
  712. ³         ³       ³          ³   d = Frequency Value Data (upper 3-bits)   ³
  713. ³         ³       ³          ³   t = Active Time Length                    ³
  714. ³         ³       ³          ³                                             ³
  715. ³         ³       ³          ³ NOTE: The Frequency Value is a full 11-bits ³
  716. ³         ³       ³          ³       in size; be aware you will need to    ³
  717. ³         ³       ³          ³       write the upper 3-bits to $400F.      ³
  718. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  719. ³ $4010   ³ RW    ³ CChessss ³ PCM Control Register #1                     ³
  720. ³         ³       ³          ³                                             ³
  721. ³         ³       ³          ³   C = Duty Cycle (Positive vs. Negative)    ³
  722. ³         ³       ³          ³        00 = 87.5%                           ³
  723. ³         ³       ³          ³        01 = 75.0%                           ³
  724. ³         ³       ³          ³        10 = 58.0%                           ³
  725. ³         ³       ³          ³        11 = 25.0%                           ³
  726. ³         ³       ³          ³   h = Hold Note                             ³
  727. ³         ³       ³          ³         0 = Don't hold note                 ³
  728. ³         ³       ³          ³         1 = Hold note                       ³
  729. ³         ³       ³          ³   e = Envelope Select                       ³
  730. ³         ³       ³          ³         0 = Envelope Vary                   ³
  731. ³         ³       ³          ³         1 = Envelope Fixed                  ³
  732. ³         ³       ³          ³   s = Playback Rate                         ³
  733. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  734. ³ $4011   ³ RW    ³ vvvvvvvv ³ PCM Volume Control Register                 ³
  735. ³         ³       ³          ³                                             ³
  736. ³         ³       ³          ³   v = Volume                                ³
  737. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  738. ³ $4012   ³ RW    ³ aaaaaaaa ³ PCM Address Register                        ³
  739. ³         ³       ³          ³                                             ³
  740. ³         ³       ³          ³   a = Address                               ³
  741. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  742. ³ $4013   ³ RW    ³ LLLLLLLL ³ PCM Data Length Register                    ³
  743. ³         ³       ³          ³                                             ³
  744. ³         ³       ³          ³   L = Data Size/Length                      ³
  745. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  746. ³ $4014   ³  W    ³          ³ Sprite DMA                         [SPRDMA] ³
  747. ³         ³       ³          ³                                             ³
  748. ³         ³       ³          ³  Transfers 256 bytes of memory at address   ³
  749. ³         ³       ³          ³  $100*N, where N is the value written to    ³
  750. ³         ³       ³          ³  this register, into Sprite RAM.            ³
  751. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  752. ³ $4015   ³ RW    ³ 000abcde ³ Sound Control Register             [SNDCNT] ³
  753. ³         ³       ³          ³                                             ³
  754. ³         ³       ³          ³  e = Channel 1  (0=Disable, 1=Enable)       ³
  755. ³         ³       ³          ³  d = Channel 2  (0=Disable, 1=Enable)       ³
  756. ³         ³       ³          ³  c = Channel 3  (0=Disable, 1=Enable)       ³
  757. ³         ³       ³          ³  b = Channel 4  (0=Disable, 1=Enable)       ³
  758. ³         ³       ³          ³  a = Channel 5  (0=Disable, 1=Enable)       ³
  759. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  760. ³ $4016   ³ RW    ³ ???STeed ³ Joypad #1                         [SPECIO1] ³
  761. ³         ³       ³          ³ [READING]                                   ³
  762. ³         ³       ³          ³                                             ³
  763. ³         ³       ³          ³  S = Zapper sprite detection                ³
  764. ³         ³       ³          ³         0 = Sprite not detected             ³
  765. ³         ³       ³          ³         1 = Sprite detected in front of     ³
  766. ³         ³       ³          ³             crosshair                       ³
  767. ³         ³       ³          ³  T = Zapper trigger                         ³
  768. ³         ³       ³          ³         0 = Pressed                         ³
  769. ³         ³       ³          ³         1 = Not pressed                     ³
  770. ³         ³       ³          ³  e = Expansion Port Data                    ³
  771. ³         ³       ³          ³  d = Joypad Data (see Section #8)           ³
  772. ³         ³       ³          ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  773. ³         ³       ³ ?????eej ³ [WRITING]                                   ³
  774. ³         ³       ³          ³                                             ³
  775. ³         ³       ³          ³  j = Joypad Strobe                          ³
  776. ³         ³       ³          ³         0 = Clear joypad strobe             ³
  777. ³         ³       ³          ³         1 = Reset joypad strobe             ³
  778. ³         ³       ³          ³                                             ³
  779. ³         ³       ³          ³  e = Expansion Port Data                    ³
  780. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  781. ³ $4017   ³ R     ³ ?????eed ³ Joypad #2                         [SPECIO2] ³
  782. ³         ³       ³          ³ [READING]                                   ³
  783. ³         ³       ³          ³                                             ³
  784. ³         ³       ³          ³  e = Expansion Port Data                    ³
  785. ³         ³       ³          ³  d = Joypad Data (see Section #8)           ³
  786. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  787.  
  788.  
  789.  
  790. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  791. ³ 7 ³   VBL/Hit Bits   ³
  792. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  793.  
  794.    The VBlank flag is contained in the 7th bit of read-only location $2002.
  795. It indicates whether PPU is scanning the screen, or generating a vertical
  796. blanking impulse. It is set in the end of each frame (scanline 232), and
  797. stays on until the next screen refresh starts from scanline 8. The pro-
  798. gram can reset this bit prematurely by reading $2002.
  799.  
  800.    The Hit Flag is contained in the 6th bit of read-only location $2002. 
  801. It goes to 1 when PPU starts refreshing the first scanline where sprite#0
  802. is located. For example, if sprite#0's Y coordinate is 34, the Hit flag
  803. will be set in scanline 34. The Hit flag is reset when vertical blanking
  804. impulse starts. The program can reset this bit prematurely by reading from
  805. $2002.
  806.  
  807.  
  808.  
  809. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  810. ³ 8 ³   Joypad/Zapper   ³
  811. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  812.  
  813.   There are two joysticks which are accessed via locations $4016 and
  814. $4017. To reset joysticks, write first 1, then 0 into $4016. This way, you
  815. will generate a strobe in the joysticks' circuitry. Then, read either from
  816. $4016 (for joystick 0) or from $4017 (for joystick 1).  Each read will
  817. give you the status of a single button in the 0th bit (1 if pressed, 0
  818. otherwise): 
  819.  
  820.   ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÂÄÄÄÄÄÄÂÄÄÄÄÄÄÂÄÄÄÄÄÄÄ¿
  821.   ³ Read # ³  1  ³  2  ³   3    ³   4   ³ 5  ³  6   ³  7   ³   8   ³
  822.   ÀÄÄÄÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÅÄÄÄÄÄÄÅÄÄÄÄÄÄÅÄÄÄÄÄÄÄ´
  823.            ³  A  ³  B  ³ SELECT ³ START ³ UP ³ DOWN ³ LEFT ³ RIGHT ³
  824.            ÀÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ
  825.  
  826.   Bit 1 indicates whether joystick is connected to the port or not. It is
  827. set to 0 if the joystick is connected, 1 if not. Bits 6 and 7 of $4016
  828. and $4017 also seem to have some significance, which is not clear yet.
  829. The rest of bits is set to zeroes. Some games expect to get *exactly* $41
  830. from $4016/$4017, if a button is pressed, which has to be taken into
  831. account. 
  832.  
  833.   For Zapper (Light Gun) information, see Section #6.
  834.  
  835.  
  836.  
  837. ÚÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  838. ³ 9 ³   Sprites   ³
  839. ÀÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  840.  
  841.   There are 64 sprites, which can be either 8x8 or 8x16 pixels. Sprites
  842. patterns are stored in on of the Pattern Tables in the PPU Memory. Sprite
  843. attributes are stored in the Sprite RAM of 256 bytes, which is not a
  844. part of neither CPU nor PPU address space. The entire contents of Sprite
  845. Memory can be written via DMA (see Section #6). Sprite RAM can also be
  846. accessed byte-by-byte by putting the starting address into $2003 and then
  847. writing/reading $2004 (the address will auto-increment). The format of
  848. Sprite RAM is as follows:
  849.  
  850. ÚÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ¿
  851. ³ Sprite #0 ³ Sprite #1 ³ ... ³ Sprite #62 ³ Sprite #63 ³
  852. ÀÄÄÄÄÄÂÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ
  853.       ³    ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  854.       ÀÄÄÄÄ´ Byte # ³ Bits     ³ Description                             ³
  855.            ÃÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  856.            ³   0    ³ YYYYYYYY ³ Sprite Y coordinate - 1. Consider the   ³
  857.            ³        ³          ³ coordinate the upper-left corner of     ³
  858.            ³        ³          ³ the sprite itself.                      ³
  859.            ³   1    ³ IIIIIIII ³ Sprite Tile Index #                     ³
  860.            ³   2    ³ vhp000cc ³ Colour/Attributes                       ³
  861.            ³        ³          ³  v = Vertical Flip   (1=Flip)           ³
  862.            ³        ³          ³  h = Horizontal Flip (1=Flip)           ³
  863.            ³        ³          ³  p = Sprite Priority Bit                ³
  864.            ³        ³          ³         0 = Sprite on top of background ³
  865.            ³        ³          ³         1 = Sprite behind background    ³
  866.            ³        ³          ³  c = Upper two (2) bits of colour       ³
  867.            ³   3    ³ XXXXXXXX ³ Sprite X coordinate (upper-left corner) ³
  868.            ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  869.  
  870.   The Sprite Tile Index # is obtained the same way as Tile Index #s are
  871. in regards to the Name Table (background) picture.
  872.  
  873.   For 8x16 sprites, the Pattern Table is at $0000 in VRAM, containing 256
  874. 8x16 tiles. Bit #3 of $2000 (see Section #6) has no effect on 8x16 sprites.
  875. The Sprite Tile Index # in the Sprite Attribute RAM is rotated right
  876. one (1) bit by the PPU, when drawing. Therefore, a Tile Index # $01 will
  877. draw tile #128, $02 would draw tile #1, $03 would draw tile #129, etc..
  878.  
  879.   The Sprite Priority bit works as follows: Sprites with a lower Sprite
  880. Tile Index # will have a higher priority (e.g. #0 will be drawn over #1).
  881.  
  882.   Only eight (8) sprites can be displayed per scan-line. Each Sprite entry
  883. in Sprite RAM is checked to see if it's in a horizontal range with the
  884. other sprites. Remember, this is done on a per scan-line basis, not on a
  885. per sprite basis (e.g. this is done 256 times, not 256/8 or 256/16 times).
  886.  
  887.  
  888.  
  889. ÚÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
  890. ³ 10 ³   MMCs   ³
  891. ÀÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
  892.  
  893.   Each reference number below (e.g. "3)" or "1)") is the iNES Mapper
  894. number. The actual MMC title is printed after, if one is available. Do not
  895. get these confused.
  896.  
  897.  
  898. 1) Nintendo MMC1
  899.  
  900.   This mapper is commonly used in 256K carts, such as Bomberman 2,
  901. Destiny Of The Emperor, Megaman 2, Airwolf, Operation Wolf, Castlevania 2,
  902. SilkWorm, and others. It may be used to switch PRG-ROM and CHR-RAM.  This
  903. MMC also supports WRAM.
  904.  
  905.   MMC1 has four (4) 8 bit registers, which are accessed via following
  906. addresses:
  907.  
  908. ÚÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  909. ³ Reg # ³ Range ³ Bits     ³ Description                                ³
  910. ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  911. ³   0   ³ $8000 ³ ???sBKpm ³ Mapper Control Register #1                 ³
  912. ³       ³  ...  ³          ³                                            ³
  913. ³       ³ $9FFF ³          ³  s = Size Select                           ³
  914. ³       ³       ³          ³         0 = Select 8K CHR-RAM at $0000     ³
  915. ³       ³       ³          ³         1 = Swap 4K at $0000 and $1000     ³
  916. ³       ³       ³          ³  B = Base Bootup Select                    ³
  917. ³       ³       ³          ³         0 = $8000 (Note: This is probably  ³
  918. ³       ³       ³          ³         1 = $C000        incorrect!)       ³
  919. ³       ³       ³          ³  K = Bank Size                             ³
  920. ³       ³       ³          ³         0 = 16K                            ³
  921. ³       ³       ³          ³         1 = 32K                            ³
  922. ³       ³       ³          ³  p = Panning/Scrolling Enable/Disable      ³
  923. ³       ³       ³          ³         0 = Enabled                        ³
  924. ³       ³       ³          ³         1 = Disabled                       ³
  925. ³       ³       ³          ³  m = Mirror Select                         ³
  926. ³       ³       ³          ³         0 = Horizontal Mirroring           ³
  927. ³       ³       ³          ³         1 = Vertical Mirroring             ³
  928. ³       ³       ³          ³                                            ³
  929. ³       ³       ³          ³ NOTE: Bit #1, when set to 1, actually just ³
  930. ³       ³       ³          ³       mirrors Name Table #0 throughout all ³
  931. ³       ³       ³          ³       the other Name Tables.               ³
  932. ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  933. ³   1   ³ $A000 ³ ssssssss ³ CHR-RAM Page Selection Register            ³
  934. ³       ³  ...  ³          ³                                            ³
  935. ³       ³ $BFFF ³          ³  Sets the CHR-RAM page at $0000, with the  ³
  936. ³       ³       ³          ³  size selected via Register #0.            ³
  937. ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  938. ³   2   ³ $C000 ³ ssssssss ³ CHR-RAM 4K Page Selection Register         ³
  939. ³       ³  ...  ³          ³                                            ³
  940. ³       ³ $DFFF ³          ³  Sets the 4K CHR-RAM page at $1000, but    ³
  941. ³       ³       ³          ³  only if 4K CHR-RAM pages are selected via ³
  942. ³       ³       ³          ³  Register #0 (otherwise ignored).          ³
  943. ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  944. ³   3   ³ $E000 ³ ssssssss ³ PRG-ROM 16K Page Selection Register        ³
  945. ³       ³  ...  ³          ³                                            ³
  946. ³       ³ $FFFF ³          ³  Sets the 16K ROM page at $8000. The page  ³
  947. ³       ³       ³          ³  at $C000 is hardwired to the last ROM     ³
  948. ³       ³       ³          ³  page in the cart. Page 0 starts at $8000. ³
  949. ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  950.  
  951.    Before writing to a mapper register for the first time, you need to reset
  952. it by setting bit #7 in each address range base ($8000, $A000, $C000, and
  953. $E000) before writing data to each address range itself. Once you've
  954. done this, you may write the value bit by bit to the appropriate address
  955. range. For example, the following code will write $0C into register 3:
  956.  
  957.      lda  #%10000000
  958.      sta  $8000      ; Resetting range #0
  959.      sta  $A000      ; Resetting range #1
  960.      sta  $C000      ; Resetting range #2
  961.      sta  $E000      ; Resetting range #3
  962.      lda  #$0C       ; This is our value
  963.      sta  $EFD9      ; Writing bit 0
  964.      lsr  a          ; Shifting
  965.      sta  $EFD9      ; Writing bit 1
  966.      lsr  a          ; Shifting
  967.      sta  $EFD9      ; Writing bit 2
  968.      lsr  a          ; Shifting
  969.      sta  $EFD9      ; Writing bit 3
  970.      lsr  a          ; Shifting
  971.      sta  $EFD9      ; Writing bit 4
  972.  
  973.  
  974. 2) 74HC161/74HC32 Mapper
  975.  
  976.   This is a quite simple mapper used in most Konami (Life Force,
  977. Castlevania, Metal Gear) and some other cartridges (Ghosts & Goblins). It
  978. only switches the ROM. All cartridges with this mapper have 8kB CHR-RAM
  979. at $0000. The mapper has a single 8 bit register which can be written via
  980. locations $8000-$FFFF. It contains a number of 16K PRG-ROM page at $8000.
  981. The page at $C000 is always hardwired to the last ROM page in the cart.
  982. The cartridge starts with page 0 at $8000.
  983.  
  984.  
  985. 3) VROM Switch
  986.  
  987.   This mapper is used in the Goonies series and many Japanese-only games.
  988. It only allows you to switch 8kB pages of CHR-ROM. The PRG-ROM is either
  989. 16K or 32K and is not paged. The mapper has a single 8-bit register which
  990. can be written via locations $8000-$FFFF. It contains a number of the 8K
  991. CHR-ROM page at $0000.
  992.  
  993.  
  994. 4) Nintendo MMC3
  995.  
  996.   This MMC is used in many recent cartridges, such as: Batman Returns,
  997. Super Contra, Vindicators, Silver Surfer, Crystalis, Legacy of the Wizard,
  998. and others. This MMC is able to generate it's own interrupts via the IRQ
  999. line, and has a set of commands to switch PRG-ROM and CHR-RAM. CHR-RAM
  1000. pages are 1K, PRG-ROM are 8K.
  1001.  
  1002.  
  1003.   NOTE: The ROM pages at $C000 and $E000 are hardwired to the last pages
  1004. of the ROM, and are not switchable. However, they can be swapped via $E000
  1005. though.
  1006.  
  1007. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1008. ³ Address ³ Stats ³ Bits     ³ Description                                 ³
  1009. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1010. ³ $8000   ³  W ?  ³ as???ddd ³ Function Select Register                    ³
  1011. ³         ³       ³          ³                                             ³
  1012. ³         ³       ³          ³    a = CHR-RAM Base Address Select          ³
  1013. ³         ³       ³          ³         0 = $0000                           ³
  1014. ³         ³       ³          ³         1 = $1000                           ³
  1015. ³         ³       ³          ³    s = CHR-RAM Page Base Select (CMDs 6/7)  ³
  1016. ³         ³       ³          ³         0 = Select $8000 and $A000          ³
  1017. ³         ³       ³          ³         1 = Select $A000 and $C000          ³
  1018. ³         ³       ³          ³  ddd = Function # (0-7)                     ³
  1019. ³         ³       ³          ³                                             ³
  1020. ³         ³       ³          ³ NOTE: Writing to this register resets       ³
  1021. ³         ³       ³          ³       changes made to the $E000 register.   ³
  1022. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1023. ³ $8001   ³  W    ³ dddddddd ³ Page Number Select Register                 ³
  1024. ³         ³       ³          ³                                             ³
  1025. ³         ³       ³          ³  This register selects the page # to be     ³
  1026. ³         ³       ³          ³  read from (or written to).                 ³
  1027. ³         ³       ³          ³                                             ³
  1028. ³         ³       ³          ³ NOTE: When using CMD 0, Bit #0 of this reg- ³
  1029. ³         ³       ³          ³       ister is ignored. Therefore, a value  ³
  1030. ³         ³       ³          ³       of 5 will select pages 4 & 5).        ³
  1031. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1032. ³ $A000   ³  W    ³ ???????m ³ Shadow Select Register                      ³
  1033. ³         ³       ³          ³                                             ³
  1034. ³         ³       ³          ³  m = Shadowing                              ³
  1035. ³         ³       ³          ³         0 = Vertical                        ³
  1036. ³         ³       ³          ³         1 = Horizontal                      ³
  1037. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1038. ³ $A001   ³  W ?  ³ p??????? ³ Pattern Table Control Register              ³
  1039. ³         ³       ³          ³                                             ³
  1040. ³         ³       ³          ³  p = Pattern Table Enable/Disable           ³
  1041. ³         ³       ³          ³         0 = Disable use of $0000-$1FFF in   ³
  1042. ³         ³       ³          ³             VRAM                            ³
  1043. ³         ³       ³          ³         1 = Enable use of $0000-$1FFF in    ³
  1044. ³         ³       ³          ³             VRAM                            ³
  1045. ³         ³       ³          ³                                             ³
  1046. ³         ³       ³          ³ NOTE: Information here could possibly be    ³
  1047. ³         ³       ³          ³       incorrect.                            ³
  1048. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1049. ³ $C000   ³       ³ dddddddd ³ IRQ Decrement Register                      ³
  1050. ³         ³       ³          ³                                             ³
  1051. ³         ³       ³          ³  A value (1-255) is written here. The chip  ³
  1052. ³         ³       ³          ³  auto-decrements this value at every scan-  ³
  1053. ³         ³       ³          ³  line. Once 0 is hit, IRQ/BRK is executed.  ³
  1054. ³         ³       ³          ³  If 0 is stored, then this feature is dis-  ³
  1055. ³         ³       ³          ³  abled.                                     ³
  1056. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1057. ³ $C001   ³  W    ³          ³ Temporary Latch Register                    ³
  1058. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1059. ³ $E000   ³  W    ³          ³ IRQ Control Register #1                     ³
  1060. ³         ³       ³          ³                                             ³
  1061. ³         ³       ³          ³  Any writes which occur to this register    ³
  1062. ³         ³       ³          ³  will cause the value written to $C001 to   ³
  1063. ³         ³       ³          ³  be copied into $C000. IRQs are also dis-   ³
  1064. ³         ³       ³          ³  abled as well.                             ³
  1065. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1066. ³ $E001   ³  W    ³          ³ IRQ Control Register #2                     ³
  1067. ³         ³       ³          ³                                             ³
  1068. ³         ³       ³          ³  Any writes to this register enable IRQs.   ³
  1069. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1070.  
  1071.   In order to make the MMC function, you must first write a Command Number
  1072. (CMD #) into $8000, and then a value (Page Number) into $8001. The follow-
  1073. ing CMDs exist:
  1074.  
  1075. ÚÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1076. ³ CMD # ³ Address ³ Description                                            ³
  1077. ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1078. ³   0   ³ $0000   ³ Selects two (2) 1K CHR-RAM pages at the Address.       ³
  1079. ³   1   ³ $0800   ³ Selects two (2) 1K CHR-RAM pages at the Address.       ³
  1080. ³   2   ³ $1000   ³ Selects one (1) 1K CHR-RAM pages at the Address.       ³
  1081. ³   3   ³ $1400   ³ Selects one (1) 1K CHR-RAM pages at the Address.       ³
  1082. ³   4   ³ $1800   ³ Selects one (1) 1K CHR-RAM pages at the Address.       ³
  1083. ³   5   ³ $1C00   ³ Selects one (1) 1K CHR-RAM pages at the Address.       ³
  1084. ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1085. ³   6   ³ N/A     ³ Selects one (1) 8K PRG-ROM Page at the CHR-RAM Page    ³
  1086. ³       ³         ³ Base Select. Initial value is 0.                       ³
  1087. ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1088. ³   7   ³ N/A     ³ Selects one (1) 8K PRG-ROM Page at the CHR-RAM Page    ³
  1089. ³       ³         ³ Base Select. Initial value is 1.                       ³
  1090. ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1091.  
  1092.   NOTE: For CMDs 0-5, see MMC Register $8001. For CMDs 6-7, see MMC Reg-
  1093. ister $8000.
  1094.  
  1095.   NOTE: Address is really "CHR-RAM Base Address XOR (Address)". Therefore,
  1096. if the CHR-RAM Base Address is set to $1000, then using CMD #4 would
  1097. result in a transfer to $2800 in VRAM.
  1098.  
  1099.  
  1100. 5) Nintendo MMC5
  1101.  
  1102.   This mapper is used in Castlevania III. It supports a four-screen Name
  1103. Table layout, allowing four (4) physical Name Tables to be used.
  1104.  
  1105.   This mapper supports a 1K section of external RAM (EXRAM), which is
  1106. mapped to $5C00-$5FFF. EXRAM holds one (1) byte corrisponding to each of
  1107. the 960 8x8 tiles. The format of an EXRAM byte is:
  1108.  
  1109. ÚÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1110. ³ Bits     ³ Description                                     ³
  1111. ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1112. ³ ccIIIIII ³ c = Colour Expansion                            ³
  1113. ³          ³                                                 ³
  1114. ³          ³       Used to remove the annoying 4x4 tile      ³
  1115. ³          ³       Attribute Bit limitation. Using these     ³
  1116. ³          ³       bits is optional.                         ³
  1117. ³          ³                                                 ³
  1118. ³          ³ I = Index Expansion                             ³
  1119. ³          ³                                                 ³
  1120. ³          ³       Extends the maximum Index Tile #s from    ³
  1121. ³          ³       256 to 16384 (8-bits to 14-bits), by      ³
  1122. ³          ³       using these six (6) in the Name Table,    ³
  1123. ³          ³       e.g.:                                     ³
  1124. ³          ³                                                 ³
  1125. ³          ³        IIIIIInnnnnnnn                           ³
  1126. ³          ³        ÀÄÄÂÄÙÀÄÄÄÂÄÄÙ                           ³
  1127. ³          ³           ³      ÀÄÄÄ Name Table                ³
  1128. ³          ³           ÀÄÄÄÄÄÄÄÄÄÄ Index Expansion           ³
  1129. ÀÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1130.  
  1131.   A register at $5104 can control whether the CPU can write to EXRAM or
  1132. not, and also controls if the Colour Expansion bits in the EXRAM are used
  1133. or not
  1134.  
  1135.   It also seems MMC5 has a register which can flip between Vertical and
  1136. Horizontal mirroring. This register is definitely used in Castlevania III.
  1137.  
  1138.  
  1139. 6) FFE F4xxx Mapper
  1140.  
  1141.   (Thanks to FanWen for this information!)
  1142.  
  1143.   This mapper allows swapping of PRG-ROM, and supports four (4) Pattern
  1144. Tables. This mapper was invented by FFE (Front Far East), and seems to
  1145. only be used on F4xxx-style games, such as the famous Wai Wai World
  1146. ("Konami World"), and others. It also supports IRQ and counter registers,
  1147. resembling that of Nintendo's MMC3.
  1148.  
  1149.   Two styles of data can be written here, but most of the time, the format
  1150. of the more commonly used data (used in "Wai Wai World") is:
  1151.  
  1152. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1153. ³ Address ³ Stats ³ Bits     ³ Description                                 ³
  1154. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1155. ³ $42FC   ³  W    ³ pppppppp ³ PRG-ROM Write Enable                        ³
  1156. ³ $42FD   ³  W    ³ mmmmmmmm ³ Mirroring Write Enable                      ³
  1157. ³ $42FE   ³  W    ³ ???p???? ³ PRG-ROM Swap                                ³
  1158. ³ $42FF   ³  W    ³ ???m???? ³ Mirroring Select                            ³
  1159. ³         ³       ³          ³    m = Mirroring Select                     ³
  1160. ³         ³       ³          ³        0 = Vertical                         ³
  1161. ³         ³       ³          ³        1 = Horizontal                       ³
  1162. ³ $43FE   ³  W    ³ CCCCCCpp ³ 4mb PRG-ROM/CHR-RAM Select                  ³
  1163. ³ $4500   ³ RW    ³ eXssWPPP ³ Configuration Register                      ³
  1164. ³         ³       ³          ³    e = Disk/Cart Mode                       ³
  1165. ³         ³       ³          ³          0 = Famicom Disk game              ³
  1166. ³         ³       ³          ³          1 = Famicom cart                   ³
  1167. ³         ³       ³          ³    X = Execute Mode                         ³
  1168. ³         ³       ³          ³          0 = Do nothing                     ³
  1169. ³         ³       ³          ³          1 = Execute game                   ³
  1170. ³         ³       ³          ³    s = SRAM Availability                    ³
  1171. ³         ³       ³          ³          0 = Not used                       ³
  1172. ³         ³       ³          ³          1 = SRAM used                      ³
  1173. ³         ³       ³          ³    W = SW Pin                               ³
  1174. ³         ³       ³          ³  PPP = PPU Mode                             ³
  1175. ³         ³       ³          ³        010 = 256K                           ³
  1176. ³         ³       ³          ³        101 = 2M + Extended VRAM             ³
  1177. ³         ³       ³          ³        111 = 2M                             ³
  1178. ³ $4501   ³  W    ³ iiiiiiii ³ IRQ Disable                                 ³
  1179. ³ $4502   ³  W    ³ iiiiiiii ³ IRQ Increment Register (low byte)           ³
  1180. ³ $4503   ³  W    ³ iiiiiiii ³ IRQ Enable & Increment Register (high byte) ³
  1181. ³ $8000   ³ RW    ³ 00ppppCC ³ PRG-ROM/CHR-RAM Control Register            ³
  1182. ³ $A000   ³       ³          ³                                             ³
  1183. ³ $C000   ³       ³          ³    p = 16K PRG-ROM Select                   ³
  1184. ³ $E000   ³       ³          ³         Selects 16K PRG-ROM bank at $8000   ³
  1185. ³         ³       ³          ³   CC = Pattern Table Select                 ³
  1186. ³         ³       ³          ³         Selects Pattern Table #0-3          ³
  1187. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1188.  
  1189.   The support of an IRQ counter is very similar to that of MMC3, except
  1190. that it is incremented and not decremented. When the value reaches $FFFF,
  1191. it will be reset to $0000. To enable the use of the IRQ counter, store
  1192. the value $0000 into $4503.
  1193.  
  1194.   This mapper also supports the use of a trainer. The trainer is loaded at
  1195. $7000-71FF. Each described item below is actual 6502 code, and not a
  1196. vector (e.g. JMP $xxxx). The address itself *IS* the vector.
  1197.  
  1198. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1199. ³ Address ³ Description                                 ³
  1200. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1201. ³ $7000   ³ NMI                                         ³
  1202. ³ $7003   ³ Game Setup code                             ³
  1203. ³ $7006   ³ Mirroring Switch                            ³
  1204. ³ $7009   ³ Other trainer routines                      ³
  1205. ³  ...    ³                                             ³
  1206. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1207.  
  1208.   NOTE: It seems most these images are purely PRG-ROM; i.e. no CHR-RAM. All
  1209. the CHR-RAM is kept inside the PRG-ROM, which is swapped in and out during
  1210. runtime via the MMC.
  1211.  
  1212.   The documentation here is still not complete; for a more accurate and
  1213. detailed documentation, please check out FanWen's document regarding
  1214. Mapper #6 via this URLL
  1215.  
  1216.   http://nesdev.parodius.com/mapper6.txt
  1217.  
  1218.  
  1219. 7) ROM Switch
  1220.  
  1221.    This mapper is used in Wizards & Warriors (1 & 2) and Deadly Towers.
  1222.  
  1223.    Writes to $8000-$FFFF select the 32K PRG-ROM bank at $8000. Bit #4
  1224. controls which Name Table and Attribute Table to use; the other Name Tables
  1225. and Attribute Tables mirror the table selected using Bit #4.
  1226.  
  1227.  
  1228. 8) FFE F3xxx Mapper
  1229.  
  1230.    No information is currently available.
  1231.  
  1232.  
  1233. 9) Nintendo MMC2
  1234.  
  1235.   This MMC is used in the American version of the "Mike Tyson's Punch-Out!"
  1236. cart. It supports switching of PRG-ROM and CHR-RAM.
  1237.  
  1238.   All PRG-ROM banks are 8K (vs. 16K) in size, with a base ROM address of
  1239. $8000. CHR-RAM banks appear to be 4K in size, 
  1240.  
  1241. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1242. ³ Address ³ Stats ³ Bits     ³ Description                                 ³
  1243. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1244. ³ $A000   ³  W    ³ dddddddd ³ PRG-ROM 8K Page Select Register             ³
  1245. ³  ...    ³       ³          ³                                             ³
  1246. ³ $AFFF   ³       ³          ³    d = 8K PRG-ROM Select                    ³
  1247. ³         ³       ³          ³         Selects 8K PRG-ROM bank at $8000.   ³
  1248. ³         ³       ³          ³                                             ³
  1249. ³ $B000   ³  W    ³ dddddddd ³ CHR-RAM 4K Page Select Register #1          ³
  1250. ³ $C000   ³       ³          ³                                             ³
  1251. ³         ³       ³          ³    d = 4K CHR-RAM Select                    ³
  1252. ³         ³       ³          ³         Selects 4K CHR-RAM bank at VRAM     ³
  1253. ³         ³       ³          ³         address $0000.                      ³
  1254. ³         ³       ³          ³                                             ³
  1255. ³ $D000   ³  W    ³ dddddddd ³ CHR-RAM 4K Page Select Register #2          ³
  1256. ³ $E000   ³       ³          ³                                             ³
  1257. ³         ³       ³          ³    d = 4K CHR-RAM Select                    ³
  1258. ³         ³       ³          ³         Selects 4K CHR-RAM bank at VRAM     ³
  1259. ³         ³       ³          ³         address $1000.                      ³
  1260. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1261.  
  1262.   The last three (3) PRG-ROM banks in the cart itself are hardwired to the
  1263. last three (3) 8K sections of ROM. For instance, in the case of "Mike
  1264. Tyson's Punch-Out!" which has sixteen (16) 8K PRG-ROM banks, PRG-ROM
  1265. bank #13, #14, and #15 would be mapped to $A000, $C000, and $E000, respec-
  1266. tively.
  1267.  
  1268.   NOTE: The CHR-RAM 4K Page Select Register seem to work in congruency;
  1269. by this I mean, when data is written to $B000, $D000 will function, but
  1270. $E000 will not (and therefore, the same rules apply to $C000/$E000 where
  1271. $D000 will not work).
  1272.  
  1273.  
  1274. 10) [Unused]
  1275.  
  1276. 11) Color Dreams Mapper
  1277.  
  1278.   This mapper is commonly used in Color Dreams games, but not all of
  1279. them will function correctly when using this mapper.
  1280.  
  1281.   PRG-ROM banks are 32K in size, and CHR-RAM banks are 8K.
  1282.  
  1283. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1284. ³ Address ³ Stats ³ Bits     ³ Description                                 ³
  1285. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1286. ³ $8000   ³  W    ³ CCCCpppp ³ PRG-ROM/CHR-RAM Page Select Register        ³
  1287. ³  ...    ³       ³          ³                                             ³
  1288. ³ $FFFF   ³       ³          ³    C = 8K CHR-RAM Select                    ³
  1289. ³         ³       ³          ³         Selects 8K CHR-RAM bank at VRAM     ³
  1290. ³         ³       ³          ³         address $0000.                      ³
  1291. ³         ³       ³          ³    p = 32K PRG-ROM Select                   ³
  1292. ³         ³       ³          ³         Selects 32K PRG-ROM bank at $8000.  ³
  1293. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1294.  
  1295.  
  1296. 12) [Unused]
  1297.  
  1298. 13) [Unused]
  1299.  
  1300. 14) [Unused]
  1301.  
  1302. 15) 100-in-1 Mapper
  1303.  
  1304.    NOTE: Assume ROM16k[] is an array of 16K PRG-ROM Banks.
  1305.    NOTE: Unlike other MMCs, the 16K of PRG-ROM loaded into $C000 on startup
  1306.          is the second 16K PRG-ROM page, not the last 16K PRG-ROM page.
  1307.  
  1308. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1309. ³ Address ³ Stats ³ Bits     ³ Description                                 ³
  1310. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1311. ³ $8000   ³  W ?  ³ smNNNNNN ³ PRG-ROM Control Register #1                 ³
  1312. ³         ³       ³          ³                                             ³
  1313. ³         ³       ³          ³    s = Swap 8K Pages                        ³
  1314. ³         ³       ³          ³         Swaps 8K at $8000 and $A000         ³
  1315. ³         ³       ³          ³         Swaps 8K at $C000 and $E000         ³
  1316. ³         ³       ³          ³    m = Mirroring Control                    ³
  1317. ³         ³       ³          ³         0 = Vertical                        ³
  1318. ³         ³       ³          ³         1 = Horizontal                      ³
  1319. ³         ³       ³          ³    N = PRG-ROM Page Select                  ³
  1320. ³         ³       ³          ³         $8000 now holds ROM16k[N]           ³
  1321. ³         ³       ³          ³         $C000 now holds ROM16k[N+1]         ³
  1322. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1323. ³ $8001   ³  W    ³ s?NNNNNN ³ PRG-ROM Control Register #2                 ³
  1324. ³         ³       ³          ³                                             ³
  1325. ³         ³       ³          ³    s = Swap 8K Pages                        ³
  1326. ³         ³       ³          ³         Swaps 8K at $C000 and $E000         ³
  1327. ³         ³       ³          ³    N = PRG-ROM Page Select                  ³
  1328. ³         ³       ³          ³         $C000 now holds ROM16k[N]           ³
  1329. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1330. ³ $8002   ³  W    ³ S?NNNNNN ³ PRG-ROM Control Register #3                 ³
  1331. ³         ³       ³          ³                                             ³
  1332. ³         ³       ³          ³    S = Upper/Lower 8K Select                ³
  1333. ³         ³       ³          ³         0 = Select Lower 8K of 16K segment  ³
  1334. ³         ³       ³          ³         1 = Select Upper 8K of 16K segment  ³
  1335. ³         ³       ³          ³    N = 8K PRG-ROM Page Select               ³
  1336. ³         ³       ³          ³         $8000 now holds ROM16k[N]           ³
  1337. ³         ³       ³          ³         $A000 now holds ROM16k[N]           ³
  1338. ³         ³       ³          ³         $C000 now holds ROM16k[N]           ³
  1339. ³         ³       ³          ³         $E000 now holds ROM16k[N]           ³
  1340. ³         ³       ³          ³                                             ³
  1341. ³         ³       ³          ³ NOTE: Bit 7 handles only Bits 0-5 of this   ³
  1342. ³         ³       ³          ³       register, and does not affect any     ³
  1343. ³         ³       ³          ³       other registers.                      ³
  1344. ³         ³       ³          ³                                             ³
  1345. ³         ³       ³          ³ NOTE: Bits 0-5 base their 8K Selection on   ³
  1346. ³         ³       ³          ³       Bit 7. Keep this in mind.             ³
  1347. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1348. ³ $8003   ³  W    ³ smNNNNNN ³ PRG-ROM Control Register #4                 ³
  1349. ³         ³       ³          ³                                             ³
  1350. ³         ³       ³          ³    s = Swap 8K Pages                        ³
  1351. ³         ³       ³          ³         Swaps 8K at $C000 and $E000         ³
  1352. ³         ³       ³          ³    m = Mirroring Control                    ³
  1353. ³         ³       ³          ³         0 = Vertical                        ³
  1354. ³         ³       ³          ³         1 = Horizontal                      ³
  1355. ³         ³       ³          ³    N = ROM Page Select                      ³
  1356. ³         ³       ³          ³         $C000 now holds ROM16k[N]           ³
  1357. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1358.  
  1359.  
  1360. ??) Nintendo MMC4
  1361.  
  1362.   (Thanks to FanWen for the information!)
  1363.  
  1364.   This MMC is used in the Japanese version of the "Mike Tyson's Punch-Out!"
  1365. cart. It supports switching of PRG-ROM and CHR-RAM.
  1366.  
  1367.   PRG-ROM banks are 16K in size, and CHR-RAM banks are 4K.
  1368.  
  1369. ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1370. ³ Address ³ Stats ³ Bits     ³ Description                                 ³
  1371. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1372. ³ $A000   ³  W    ³ pppppppp ³ PRG-ROM Page Select Register                ³
  1373. ³         ³       ³          ³                                             ³
  1374. ³         ³       ³          ³    p = 32K PRG-ROM Select                   ³
  1375. ³         ³       ³          ³         Selects 16K PRG-ROM bank at $8000.  ³
  1376. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1377. ³ $B000   ³  W    ³ CCCCCCCC ³ CHR-RAM Page Select Register #1             ³
  1378. ³         ³       ³          ³                                             ³
  1379. ³         ³       ³          ³    C = 4K CHR-RAM Select                    ³
  1380. ³         ³       ³          ³         Selects 4K CHR-RAM bank at VRAM     ³
  1381. ³         ³       ³          ³         address $0000.                      ³
  1382. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1383. ³ $C000   ³  W    ³ CCCCCCCC ³ CHR-RAM Page Select Register #2             ³
  1384. ³         ³       ³          ³                                             ³
  1385. ³         ³       ³          ³    C = 4K CHR-RAM Select                    ³
  1386. ³         ³       ³          ³         Selects 4K CHR-RAM bank at VRAM     ³
  1387. ³         ³       ³          ³         address $1000.                      ³
  1388. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1389. ³ $D000   ³  W    ³ CCCCCCCC ³ CHR-RAM Page Select Register #3             ³
  1390. ³         ³       ³          ³                                             ³
  1391. ³         ³       ³          ³    C = 4K CHR-RAM Select                    ³
  1392. ³         ³       ³          ³         Selects 4K CHR-RAM bank at VRAM     ³
  1393. ³         ³       ³          ³         address $0000.                      ³
  1394. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1395. ³ $E000   ³  W    ³ CCCCCCCC ³ CHR-RAM Page Select Register #4             ³
  1396. ³         ³       ³          ³                                             ³
  1397. ³         ³       ³          ³    C = 4K CHR-RAM Select                    ³
  1398. ³         ³       ³          ³         Selects 4K CHR-RAM bank at VRAM     ³
  1399. ³         ³       ³          ³         address $1000.                      ³
  1400. ÃÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1401. ³ $F000   ³  W    ³ dddddddd ³ Mirroring Select Register                   ³
  1402. ³         ³       ³          ³                                             ³
  1403. ³         ³       ³          ³    d = Mirroring Select                     ³
  1404. ³         ³       ³          ³         0 = Horizontal                      ³
  1405. ³         ³       ³          ³         1 = Vertical                        ³
  1406. ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1407.  
  1408.   This mapper has some very peculiar aspects, especially when it comes to
  1409. accessing VRAM. The CHR-RAM Page Select Registers listed above are auto-
  1410. matically "enabled" and "disabled" depending upon which address(es) in
  1411. VRAM you access.
  1412.  
  1413. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1414. ³ VRAM Address Range ³ Description                                 ³
  1415. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1416. ³ $0FD8-0FDF         ³ Switches VRAM $0000-0FFF swapping to $C000  ³
  1417. ³ $0FE8-0FEF         ³ Switches VRAM $0000-0FFF swapping to $B000  ³
  1418. ³ $1FD8-1FDF         ³ Switches VRAM $1000-1FFF swapping to $E000  ³
  1419. ³ $1FE8-1FEF         ³ Switches VRAM $1000-1FFF swapping to $D000  ³
  1420. ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1421.  
  1422.  
  1423.  
  1424. ÚÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄ¿
  1425. ³ 11 ³   Sound   ³
  1426. ÀÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÙ
  1427.  
  1428.   One of the most interesting aspects of the NES is it's sound support,
  1429. which is very analogue, excluding the PCM register.
  1430.  
  1431.   There seem to be formulaes which allow accurate playback of the NES's
  1432. sound, using the following formulaes:
  1433.  
  1434.     P = 111860.78 / (CHx + 1).
  1435.  
  1436.   Where "P" is the actual played data, and CHx is the channel played.
  1437. The channel formulaes are the following:
  1438.  
  1439.     CH1 = $4002 + ($4003 & 7) * 256   (Square Wave #1)
  1440.     CH2 = $4006 + ($4007 & 7) * 256   (Square Wave #2)
  1441.     CH3 = $400A + ($400B & 7) * 256   (Triangle Wave)
  1442.  
  1443.   Where the $400x values are actual values written to that register.
  1444.  
  1445.   Formulaes for the Noise and PCM Channels are probably not necessary,
  1446. but I'm not positive. Any information is appriciated.
  1447.  
  1448.  
  1449.  
  1450. ÚÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1451. ³ 12 ³   .NES File Format   ³
  1452. ÀÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1453.  
  1454.   This is the .NES File Format, created by Marat Fayzullin (author of
  1455. iNES).
  1456.  
  1457. ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1458. ³ Offset ³ Size ³ Content(s)                                           ³
  1459. ÃÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1460. ³   0    ³  3   ³ 'NES'                                                ³
  1461. ³   3    ³  1   ³ $1A                                                  ³
  1462. ³   4    ³  1   ³ Number of 16K PRG-ROM banks                          ³
  1463. ³   5    ³  1   ³ Number of 8K CHR-RAM banks                           ³
  1464. ³   6    ³  1   ³ ROM Control Byte                                     ³
  1465. ³        ³      ³   %00000000                                          ³
  1466. ³        ³      ³    ÀÄÂÙ³³³ÀÄ 0=Horizontal Mirroring                  ³
  1467. ³        ³      ³      ³ ³³³   1=Vertical Mirroring                    ³
  1468. ³        ³      ³      ³ ³³ÀÄÄ 1=WRAM located at $6000-7FFF            ³
  1469. ³        ³      ³      ³ ³ÀÄÄÄ 1=512-byte trainer present              ³
  1470. ³        ³      ³      ³ ÀÄÄÄÄ 1=Four-screen VRAM layout               ³
  1471. ³        ³      ³      ³                                               ³
  1472. ³        ³      ³      ÀÄÄÄÄÄÄ iNES Mapper #                           ³
  1473. ³        ³      ³                                                      ³
  1474. ³  7-15  ³  9   ³ [Reserved for expansion, should be $00]              ³
  1475. ³ 16-..  ³      ³ PRG-ROM banks (in ascending order). A trainer pre-   ³
  1476. ³        ³      ³ cedes the first bank, if a trainer exists.           ³
  1477. ³ ..-EOF ³      ³ CHR-RAM banks (in ascending order).                  ³
  1478. ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1479.  
  1480.   The previously mentioned 512-byte trainer is interesting, since it has
  1481. different implementations depending upon which iNES Mapper is used in the
  1482. cart. See Section #10 for more information about MMC-dependant trainers.
  1483.  
  1484.  
  1485.  
  1486. ÚÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1487. ³ 13 ³   Famicom Disk System Format (.DKA/.DKB/.500)   ³
  1488. ÀÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1489.  
  1490.   This is the file format for Famicom Disk System images; the only
  1491. emulator at this time to support them is Pasowing, which is the
  1492. emulator which these images are based off of.
  1493.  
  1494.    The format for the .DKA/.DKB (DisK side-A and DisK side-B) files
  1495. is somewhat undocumented (as shown). .DKA and .DKB files are 64K in
  1496. size (65536 bytes). The format for the file is as follows:
  1497.  
  1498. ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1499. ³ Offset ³ Size ³ Content(s)                                           ³
  1500. ÃÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1501. ³ [IMAGE HEADER]                                                       ³
  1502. ³                                                                      ³
  1503. ³   0    ³  1   ³ [Unknown]                                            ³
  1504. ³   1    ³  3   ³ Disk ID                                              ³
  1505. ³   6    ³  1   ³ Disk #                                               ³
  1506. ³   38   ³  1   ³ Disk # (???)                                         ³
  1507. ³   63   ³  1   ³ Amount of data blocks                                ³
  1508. ³                                                                      ³
  1509. ³ [DATA BLOCK HEADER]                                                  ³
  1510. ³                                                                      ³
  1511. ³   64   ³  1   ³ $03                                                  ³
  1512. ³   65   ³  1   ³ Block #                                              ³
  1513. ³   66   ³  1   ³ ???                                                  ³
  1514. ³   67   ³  8   ³ Name                                                 ³
  1515. ³   75   ³  2   ³ Destination                                          ³
  1516. ³   77   ³  2   ³ Size of data                                         ³
  1517. ³   79   ³  1   ³ Data Type                                            ³
  1518. ³        ³      ³ ÀÄÄÄÂÄÄÄÙ                                            ³
  1519. ³        ³      ³     ³                                                ³
  1520. ³        ³      ³     ÀÄÄÄÄÄÄ $00 = PRG-ROM                            ³
  1521. ³        ³      ³             $01 = CHR-RAM                            ³
  1522. ³        ³      ³             $02 = [Unknown]                          ³
  1523. ³ 79-..  ³      ³ Data                                                 ³
  1524. ³        ³      ³                                                      ³
  1525. ³ ..-EOF ³      ³ Repeat loading DATA BLOCKS HEADERS as shown above;   ³
  1526. ³        ³      ³ continue loading until EOF is reached.               ³
  1527. ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1528.  
  1529.  
  1530.  
  1531. ÚÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1532. ³ 14 ³   Notes to emulator authors   ³
  1533. ÀÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1534.  
  1535.   The NES is a 6502 (NMOS) CPU. It is not a 65C02 (CMOS) CPU as rumoured.
  1536.   
  1537.   Ignore opcodes which are "bad" (not in the 6502 instruction set); a lot
  1538. of ROMs available are flawed, due to bad backup units or readers. I've
  1539. noticed this in the "Twinbee" and "Adventure of Lolo" ROMs floating around.
  1540.  
  1541.   If a trainer is present in the .NES image, your emulator should load the
  1542. trainer into it's respective memory range, as well as PRG-ROM and CHR-RAM.
  1543. Begin executing code at $7000, not at the RESET vector.
  1544.  
  1545.   The Four-screen VRAM layout is used within other mappers, not just iNES
  1546. Mapper #5 (MMC5). I have seen it used in iNES Mapper #15 and others.
  1547.  
  1548.   A reminder: MMC != iNES Mapper.
  1549.  
  1550.   When the NES screen is turned off, programmers do not have to wait for
  1551. the VBL to occur. This may be pointless information to you, but for some
  1552. of you, it may be vital :-).
  1553.  
  1554.  
  1555.  
  1556. ÚÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1557. ³ 15 ³   Thanks   ³
  1558. ÀÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1559.  
  1560.   Thanks to the following people for helping make this document what it
  1561. has become today. In alphabetical order:
  1562.  
  1563.   Acey                (d0p@sofi.ah.dk)
  1564.   Alex Krasivsky      (bcat@lapkin.rosprint.ru)
  1565.   Avatar Z            (swahlen@nfinity.com)
  1566.   Bloodlust Software  (bldlust@southwind.net)
  1567.   CiXeL               (N/A)
  1568.   D                   (d@animal.blarg.net)
  1569.   Dan Boris           (dan.boris@coat.com)
  1570.   FanWen              (yangfanw@ms4.hinet.net)
  1571.   Kevin Horton        (khorton@iquest.net)
  1572.   Loopy               (loopy@itsnet.com)
  1573.   Marat Fayzullin     (fms@freeflight.com)
  1574.   Mark Knibbs         (markk@netcomuk.co.uk)
  1575.   Mike Perry          (mj-perry@uiuc.edu)
  1576.   MindRape            (mindrape@goodnet.com)
  1577.   Moo!                (danmcc@injersey.com)
  1578.   Neill Corlett       (corlett@elwha.nrrc.ncsu.edu)
  1579.   Pat Mccomack        (splat@primenet.com)
  1580.   Paul Robson         (AutismUK@aol.com)
  1581.   star69              (mr6v@andrew.cmu.edu)
  1582.   Stumble             (stumble@alpha.pulsar.net)
  1583.   Tony Young          (KBAAA@aol.com)
  1584.   Typhoon Z           (typhoonz@parodius.com)
  1585.   Vince Indriolo      (indriolo@nm.picker.com)
  1586.  
  1587.  
  1588.  
  1589. ÚÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  1590. ³ 16 ³   Revision History   ³
  1591. ÀÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1592.  
  1593.   v0.40: [---] Section #15 ("Relative URLs") removed.
  1594.          [---] Section #11 shifted down one (1) to allow for the
  1595.                addition of "Sound".
  1596.          [ #0] Updated.
  1597.          [ #1] Updated.
  1598.          [ #4] Updated.
  1599.          [ #6] PPUCNT1 is now PPUCNT0.
  1600.          [ #6] PPUCNT2 is now PPUCNT1.
  1601.          [ #6] BGSCROL ($2005) updated.
  1602.          [ #6] SNDCNT ($4015) updated.
  1603.          [ #8] Updated.
  1604.          [#10] MMC1 updated.
  1605.          [#10] Mapper #3 updated.
  1606.          [#10] MMC3 updated.
  1607.          [#10] MMC5 updated.
  1608.          [#10] Mapper #6 updated.
  1609.          [#10] Mapper #11 updated.
  1610.          [#11] Section added ("Sound").
  1611.          [#13] Updated.
  1612.          [#14] Updated.
  1613.          [#15] Updated.
  1614.   v0.34: [---] Private release.
  1615.   v0.33: [ #0] Section added.
  1616.          [#10] MMC3 layout changed.
  1617.          [#10] MMC4 added.
  1618.          [#10] Mapper #6 updated.
  1619.          [#12] Data block description updated.
  1620.          [#15] Section added.
  1621.   v0.32: [---] Private release.
  1622.   v0.31: [#10] MMC2 added.
  1623.          [#10] Mapper #11 added.
  1624.          [#10] Mapper #6 updated.
  1625.  
  1626.   v0.30: [---] First public release.
  1627.  
  1628.  
  1629.